package com.entor.service.impl;

import java.io.File;
import java.io.FileInputStream;

import org.springframework.stereotype.Service;

import com.entor.service.FileInOutService;

@Service
public class FileInOutServiceImpl implements FileInOutService{

	@Override
	public byte[] showPhote(String path) {
		File f1 = new File(path);
		if(!f1.exists()){
			System.out.println("文件不存在！");
			return null;
		}
		try {
			//声明字节输入对象
			FileInputStream fis = new FileInputStream(f1);
			//获取文件的大小
			int size = fis.available();
			//根据大小创建字节数组
			byte[] b = new byte[size];
			//读取内容放到数组中
			fis.read(b);
			//关闭流
			fis.close();
			return b;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
